package com.qk.management.mapper;

import com.qk.entity.User;
import com.qk.entity.domain.user.UserDO;
import com.qk.entity.dto.user.UserDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * @author fantuan
 * @created 2025/10/7 18:15
 * @description
 */
@Mapper
public interface UserMapper {
    List<UserDO> selectByPage(UserDTO dto);

    void insert(User user);

    void deleteById(List<Integer> ids);

    UserDO getUserById(Integer id);

    void update(User user);

    @Select("select * from user")
    List<UserDO> selectAllUsers();

    List<UserDO> listByRole(String roleLabel);

    @Select("select * from user where dept_id = #{deptId}")
    List<UserDO> listByDept(Integer deptId);

    @Select("SELECT SUBSTRING_INDEX(image, '/', -1) AS file_key FROM user WHERE image IS NOT NULL AND image != ''")
    Set<String> selectAllFileKeys();

    @Select("select * from user where username = #{username}")
    User selectByUsername(String username);
}
